package ogon.tabsadv;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.AnalogClock;
import android.widget.Button;
import android.widget.TabHost;

public class OgonTabsAdvanced extends Activity {
    /** Called when the activity is first created. */
	TabHost tabs;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tabs = (TabHost)findViewById(R.id.tabhost);
        tabs.setup();
        TabHost.TabSpec spec = tabs.newTabSpec("tag1");
        spec.setContent(R.id.tab2);
        spec.setIndicator("Button");
        tabs.addTab(spec);
        Button basicButton = (Button)tabs.getCurrentView().findViewById(R.id.tab2);
        basicButton.setOnClickListener(new View.OnClickListener() {
    		
    		@Override
    		public void onClick(View v) {
    			TabHost.TabSpec spec = tabs.newTabSpec("tag3");
    			spec.setContent(OgonNewTab);
    			spec.setIndicator("Second Clock");
    			tabs.addTab(spec);
    		}
    	});
        spec=tabs.newTabSpec("tag2");
        spec.setContent(R.id.tab1);
        spec.setIndicator("Clock");
        tabs.addTab(spec);
    }
    
	TabHost.TabContentFactory OgonNewTab = new TabHost.TabContentFactory() {
		
		@Override
		public View createTabContent(String tag) {
			// TODO Auto-generated method stub
			return(new AnalogClock(OgonTabsAdvanced.this));
		}
	};
}